import java.io.FileWriter;
import java.io.IOException;

public class Test2 {
    public static void main(String[] args) throws IOException {
        Student student = new Student("zhangsan", 28, 20);
        //我们要写人读的文件，所以要用字符流写文件
        String style = student.toString();
        fileWriterMethod("zhangsan.txt",style);

        System.out.println(student);
    }
    public static void fileWriterMethod(String filePath, String content) throws IOException {
        try (FileWriter fileWriter = new FileWriter(filePath)) {
            fileWriter.append(content);
        }
    }
}


